package com.huizu.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.huizu.common.annotation.Log;
import com.huizu.common.core.controller.BaseController;
import com.huizu.common.core.domain.AjaxResult;
import com.huizu.common.enums.BusinessType;
import com.huizu.project.domain.ProLdWc;
import com.huizu.project.service.IProLdWcService;
import com.huizu.common.utils.poi.ExcelUtil;
import com.huizu.common.core.page.TableDataInfo;

/**
 * 劳动位次配置Controller
 * 
 * @author zhangmx
 * @date 2024-05-11
 */
@RestController
@RequestMapping("/project/proldwc")
public class ProLdWcController extends BaseController
{
    @Autowired
    private IProLdWcService proLdWcService;

    /**
     * 查询劳动位次配置列表
     */
    @PreAuthorize("@ss.hasPermi('project:proldwc:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProLdWc proLdWc)
    {
        startPage();
        List<ProLdWc> list = proLdWcService.selectProLdWcList(proLdWc);
        return getDataTable(list);
    }

    /**
     * 导出劳动位次配置列表
     */
    @PreAuthorize("@ss.hasPermi('project:proldwc:export')")
    @Log(title = "劳动位次配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProLdWc proLdWc)
    {
        List<ProLdWc> list = proLdWcService.selectProLdWcList(proLdWc);
        ExcelUtil<ProLdWc> util = new ExcelUtil<ProLdWc>(ProLdWc.class);
        util.exportExcel(response, list, "劳动位次配置数据");
    }

    /**
     * 获取劳动位次配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:proldwc:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(proLdWcService.selectProLdWcById(id));
    }

    /**
     * 新增劳动位次配置
     */
    @PreAuthorize("@ss.hasPermi('project:proldwc:add')")
    @Log(title = "劳动位次配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProLdWc proLdWc)
    {
        return toAjax(proLdWcService.insertProLdWc(proLdWc));
    }

    /**
     * 修改劳动位次配置
     */
    @PreAuthorize("@ss.hasPermi('project:proldwc:edit')")
    @Log(title = "劳动位次配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProLdWc proLdWc)
    {
        return toAjax(proLdWcService.updateProLdWc(proLdWc));
    }

    /**
     * 删除劳动位次配置
     */
    @PreAuthorize("@ss.hasPermi('project:proldwc:remove')")
    @Log(title = "劳动位次配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(proLdWcService.deleteProLdWcByIds(ids));
    }
}
